def Pitch_Play(pwm,pitch,s):
    pitch=pitch/100000
    pwm.open(pitch, 50)
    Delay.Delay_ms(int(s*950))
    pwm.close()
    Delay.Delay_ms(int(s*50))
    
def Pitch_Play_HB_Start(GPIO,V2_PWM):
    Pin(GPIO, Pin.OUT,Pin.PULL_PD,0)
    pwm=PWM_V2(V2_PWM, G5/100000, 50)
    Pitch_Play(pwm,G5,0.25)
    Pitch_Play(pwm,G5,0.25)
    Pitch_Play(pwm,A5,0.5)
    Pitch_Play(pwm,G5,0.5)
    Pitch_Play(pwm,C6,0.5)
    Pitch_Play(pwm,B5,0.5)

def Pitch_Play_HB_End(GPIO,V2_PWM):
    Pin(GPIO, Pin.OUT,Pin.PULL_PD,0)
    pwm=PWM_V2(V2_PWM, G5/100000, 50)
    Pitch_Play(pwm,F5,0.25)
    Pitch_Play(pwm,F5,0.25)
    Pitch_Play(pwm,E6,0.5)
    Pitch_Play(pwm,C6,0.5)
    Pitch_Play(pwm,D6,0.5)
    Pitch_Play(pwm,C6,0.5)


def Sound_Init(path):
    Pin(Pin.GPIO29, Pin.OUT,Pin.PULL_PU,1)
    spk=audio.Audio(0)
    if spk.play(4, 1, path)==0:
        return 1
    else:
        return 0
